$(window).ready(function(){
	var userOpenId;
	
	function getOpenIdSucFn(data){
		if(data.code == "0000"){
			userOpenId = data.data;
		}else {
			console.log(data.msg);
		}
	}

	function listSucFn(data){
		if(data.code == "0000"){
			var message = data.data;
			for(var i=0; i< message.length; i++){
				if(message[i].IsEnd == true){
					continue;
				}else{
					if(message[i].ID == "1"){
						var acturl = "signTem.html";
					}else if(message[i].ID == "5"){
						var acturl = "http://cdydevent.soji.so/index.php?s=/addon/CdTurntable2/Index/index/id/249.html&openid="+userOpenId;
					}else {
						var acturl = "#";
					}
					var text = $('<div class="activity"><div class="act-img"><img src="http://ydche.com/media/mcimg/'+message[i].Image+'" />'+
					'<div class="act-num">'+message[i].JoinCount+'人已参与</div></div>'+
					'<div class="act-title"><p><img src="images/act_tip.png" /><span class="span-left">'+message[i].Topic+'</span>'+
					'<span class="span-right">'+message[i].StartTime+'</span></p></div>'+
					'<p class="act-intro">'+message[i].Summary+'</p>'+
					'<a href="'+acturl+'" class="act-more">查看详情"</a></div>');
					text.appendTo($(".actlist"));
				}
			}
		}else{
			console.log(data.msg);
		}
	}

	var urlGetOpenId = wxAddress+"/weixin/campaign/getOpenId";
	ajaxEncapsulation(urlGetOpenId, getOpenIdSucFn, "", "GET", "false");

	var urlList = wxAddress+"/weixin/campaign/list";
	ajaxEncapsulation(urlList, listSucFn, "", "GET", "true");
})